<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<!-- 使用UTF-8 -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<!-- 设置移动终端可视区域 -->
		<meta content="telephone=no" name="format-detection">
		<!-- 禁止iPhone等手机自动将数字变成可点击的拨号连接 -->
		<title>列表详情</title>
		<link href="css/style.css" type="text/css" rel="stylesheet" />
		<link href="css/weui.css" type="text/css" rel="stylesheet" />
	</head>
	<body style="background: #F6F6F6;">
		<div class="detail" id="containerVue" v-cloak>
			<div class="headerView">
				<i onclick="closeView()">&#139;</i>
				<h1>"966588"查询系统</h1>
				<div></div>
			</div>
			<div class="beforeTitle" style="text-align: center;padding-bottom: 0;font-size: 1rem;font-weight: bold;">{{info.name}}</div>
			<div class="beforeTitle">{{info.applyStatusText}}信息</div>
			<div class="cont">
				<!-- <div class="li">
					<div class="left">申请类型</div>
					<div class="right">{{applyInfo.applyStatusText}}</div>
				</div> -->
				<div class="li">
					<div class="left">{{info.applyStatusText}}意见</div>
					<div class="right">{{applyInfo.description}}</div>
				</div>
				<div class="li" v-if="info.operateStatus == '4'">
					<div class="left">{{info.applyStatusText}}时间</div>
					<div class="right">{{applyInfo.adjustTime}}</div>
				</div>
			</div>
			<div class="beforeTitle">受理信息</div>
			<div class="cont">
				<div class="li" v-if="roleCode == 'DepartLeaderRole'">
					<div class="left">审批</div>
					<div class="right">
						<div class="check">
							<input type="radio" name="radio1" :value="true" v-model="param.isPassed">同意
							<input type="radio" name="radio1" :value="false" v-model="param.isPassed">中止
						</div>
					</div>
				</div>
				<div class="li">
					<div class="left" v-if="roleCode == 'DepartLeaderRole'">初步意见</div>
					<div class="right">{{firstInfo}}</div>
				</div>
				<div class="li">
					<div class="left" v-if="roleCode == 'ProjectAdmin'">初步意见</div>
					<div class="left" v-if="roleCode == 'DepartLeaderRole'">最终意见</div>
					<div class="right"><textarea v-model="param.description"></textarea></div>
				</div>
			</div>
			<div style="height: 3.5rem;"></div>
			<div class="btn">
				<div @click="submit">提交</div>
			</div>
		</div>
		<script src="script/jquery-3.5.js"></script>
		<script src="script/vue.js"></script>
		<script src="script/api.js"></script>
		<script src="script/ajax.js"></script>
		<!-- <script src="../js/common/mui.min.js"></script> -->
		<!-- <script src="../js/common/openview.js"></script> -->
		<script>
			var app = new Vue({
				el: '#containerVue',
				data: {
					info: JSON.parse(sessionStorage.getItem('indexInfo')), // 详情信息
					applyInfo: {}, // 申请信息
					param: {
						isPassed: true,
						description: '',
					},
					roleCode: "", // 角色类型
					firstInfo: '',
				},
				created() {
					this.getApply();
					this.getRole();
				},
				mounted() {
					this.getHandle();
				},
				watch: {},
				methods: {
					// 获取初步意见信息
					getFirst() {
						let that = this;
						ajaxHttp({
							url: 'jeecg-boot/node/nodeProjectAdjustmentAudit/getBusUserOpinionByProIdAndType',
							type: 'post',
							data: {
								createTime: that.applyInfo.createTime,
								projectId: that.applyInfo.projectId,
								type: that.applyInfo.type
							},
							success: function(res) {
								console.log(JSON.stringify(res));
								if (res.success) {
									that.firstInfo = res.message
								} else {
									$.Jwarning(res.message)
								}
							}
						});
					},
					// 获取角色
					getRole() {
						let that = this;
						ajaxHttp({
							url: 'jeecg-boot/sys/role/queryRoleByUser',
							type: 'post',
							data: {},
							success: function(res) {
								// console.log(JSON.stringify(res));
								if (res.success) {
									res.result.forEach(item => {
										if (item.roleCode == "ProjectAdmin") { // 经营人员
											that.roleCode = item.roleCode;
										} else if (item.roleCode == "ProjectNodeViewRole") { // 业主
											that.roleCode = item.roleCode;
										} else if (item.roleCode == "LeaderRole") { // 领导
											that.roleCode = item.roleCode;
										} else if (item.roleCode == "DepartLeaderRole") { // 部门领导
											that.roleCode = item.roleCode;
										}
									})
									console.log(that.roleCode);
								} else {
									$.Jwarning(res.message)
								}
							},
						})
					},
					// 审批提交
					submit() {
						let that = this;
						let params = {
							proId: this.info.id,
							operateStatus: this.info.applyStatus,
							isPassed: this.param.isPassed,
							description: this.param.description
						};
						if (this.param.description == "") {
							$.Jwarning('请填写意见')
						} else {
							ajaxHttp({
								url: 'jeecg-boot/node/nodeProjectInfo/auditOperateStatusByProId',
								type: 'post',
								data: params,
								success: function(res) {
									// console.log(JSON.stringify(res));
									if (res.success) {
										$.Jsuccess('提交成功')
										setTimeout(function() {
											history.go(-2);
										}, 3000)
									} else {
										$.Jwarning(res.message)
									}
								}
							});
						}
					},
					// 获取申请信息
					getApply() {
						let that = this;
						console.log(that.info)
						ajaxHttp({
							url: 'jeecg-boot/node/nodeProjectAdjustment/getNearestOneByProId',
							type: 'post',
							data: {
								proId: that.info.id
							},
							success: function(res) {
								console.log(JSON.stringify(res));
								if (res.success) {
									that.applyInfo = res.result;
									that.getFirst();
								} else {
									$.Jwarning(res.message)
								}
							}
						});
					},
					// 获取任务调整状态
					getHandle() {
						let that = this;
						ajaxHttp({
							url: 'jeecg-boot/sys/dict/getDictItems/DutyChange',
							type: 'get',
							data: {},
							success: function(res) {
								if (res.success) {
									// console.log(JSON.stringify(that.info));
									res.result.forEach(item => {
										if (item.value == that.info.applyStatus) {
											Vue.set(that.info, 'applyStatusText', item.title)
										}
									})
								} else {
									$.Jwarning(res.message)
								}
							}
						});
					}
				}
			})
		</script>
	</body>
</html>
